<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录系统登录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/xadmin/css/font.css">
	<link rel="stylesheet" href="/xadmin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/xadmin/js/xadmin.js"></script>

</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">管理登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="uname" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <div>
                <input type="text" name="captcha" placeholder="请输入验证码" autocomplete="off" class="layui-input admin-input admin-input-verify" >
                <img style="padding: 5px;"  src="/user/register/checkCode" onclick="changeCheckCode(this)" alt="更换验证码">

                <!--                    更换验证码-->
                <script type="text/javascript">
                    //图片点击事件
                    function changeCheckCode(img) {
                        img.src = "/user/register/checkCode?" + new Date().getTime();
                    }
                </script>

            </div>
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="button">
            <hr class="hr15">
            <input value="返回"  style="width:100%;" type="button" onclick="backIndex()">

            <hr class="hr20" >
        </form>
    </div>

    <script>
        layui.use(['form'], function () {
            var form = layui.form,
                $ = layui.jquery,
                layer = layui.layer;

            // 登录过期的时候，跳出ifram框架
            if (top.location != self.location) top.location = self.location;

            // 进行登录操作
            form.on('submit(login)', function (data) {
                var param = data.field;
                if (param.uname == '') {
                    layer.msg('用户名不能为空');
                    return false;
                }
                if (param.password == '') {
                    layer.msg('密码不能为空');
                    return false;
                }
                if (param.captcha == '') {
                    layer.msg('验证码不能为空');
                    return false;
                }
                $.ajax({
                    url:'/back/user/loginResult',
                    type:'post',
                    // async:false,
                    data:JSON.stringify(param),
                    contentType: "application/json; charset=utf-8",
                    dataType:"json",
                    success:function (data){
                        // console.log("接收的数据为"+data);
                        //验证码错误或者用户不存在
                        if (data.status==400 || data.status==401||data.status==402){
                            layer.msg(data.msg,{icon:0,time :3000});
                        }
                        //登录成功
                        if (data.status==200){
                            layer.alert(data.msg,function (){
                                window.location.href='/back/index';
                            })

                        }

                    }

                });
            });
        });

        function backIndex(){
            window.location.href="/";
        }

    </script>

<!--    <script>-->
<!--        $(function  () {-->
<!--            layui.use('form', function(){-->
<!--              var form = layui.form;-->
<!--              // layer.msg('玩命卖萌中', function(){-->
<!--              //   //关闭后的操作-->
<!--              //   });-->
<!--              //监听提交-->
<!--              form.on('submit(login)', function(data){-->
<!--                // alert(888)-->
<!--                layer.msg(JSON.stringify(data.field),function(){-->
<!--                    location.href='/back/index'-->
<!--                });-->
<!--                return false;-->
<!--              });-->
<!--            });-->
<!--        })-->

<!--        -->
<!--    </script>-->

    
    <!-- 底部结束 -->
<!--    <script>-->
<!--    //百度统计可去掉-->
<!--    var _hmt = _hmt || [];-->
<!--    (function() {-->
<!--      var hm = document.createElement("script");-->
<!--      hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";-->
<!--      var s = document.getElementsByTagName("script")[0]; -->
<!--      s.parentNode.insertBefore(hm, s);-->
<!--    })();-->
<!--    </script>-->
</body>
</html>